var removeNthFromEnd = function (head, n) {
  let dummyHead = new ListNode()
  dummyHead.next = head
  if (head) {
    let fast = head, slow = dummyHead
    for (; n > 0; n--) {
      fast = fast.next
    }
    while (fast) {
      fast = fast.next
      slow = slow.next
    }
    slow.next = slow.next.next
  }
  return dummyHead.next
}

